<template>
    <el-dialog v-model="dialogFormVisible" class="eldialog">
        <el-form :model="form" label-width="120px">
        <el-form-item label="账号：" style="width: 550px;margin-left: 50px" :disabled="props.datar==null? true:false">
          <el-input :disabled="props.datar" v-model="form.usernum" />
        </el-form-item>
        <el-form-item v-if="!props.datar"  label="密码：" style="width: 550px;margin-left: 50px">
          <el-input v-model="form.password" />
        </el-form-item>
        <el-form-item v-if="!props.datar" label="确认密码：" style="width: 550px;margin-left: 50px">
          <el-input v-model="form.password2" />
        </el-form-item>
        <el-form-item label="姓名：" style="width: 550px;margin-left: 50px">
          <el-input v-model="form.name" />
        </el-form-item>
        <el-form-item label="备注：" style="width: 550px;margin-left: 50px">
          <el-input v-model="form.bz" />
        </el-form-item>
        <el-form-item label="角色：" style="width: 550px;margin-left: 50px">
          <el-select v-model="form.js" placeholder="请选择角色"  style="width: 550px;">
            <el-option label="超级管理员" value="超级管理员" />
            <el-option label="系统管理员" value="系统管理员" />
            <el-option label="服务管理员" value="服务管理员" />
          </el-select>
        </el-form-item>
    </el-form>
    <el-form-item label="">
      <div class="dialogBtn">
        <el-button @click="onSubmit(1)">取消</el-button>
        <el-button type="primary" @click="onSubmit(form)">确认新建</el-button>
      </div>
    </el-form-item>
  </el-dialog>
</template>

<script setup>
import {ref,reactive,watch} from "vue"
import {getUidToUserApi} from '@/api/adminuserApi.js';
const dialogFormVisible=ref(false)
const props=defineProps(['datar'])
let form = reactive({
    usernum: '',
    name: '',
    js: '',
    bz: '',
    password: '',
    password2: '',
})

// let ret=await getUidToUserApi(item);
// console.log(props.datar);
if(props.datar){
  // console.log(11);
  form=props.datar;
  }
// form=props.datar;//111
// console.log(form);
const emit = defineEmits(['click'])
const onSubmit=async (form)=>{
  console.log(props.datar);
  if(!props.datar){
    emit('click',form)
  }else{
    
    
    // form.value=ret.data.usernum;
    console.log(form.value);
  }
}
// watch(form,  () => {
  
// });

</script>

<style lang="scss" scoped>
.eldialog{
  width: 800px;
  height: 600px;
  
}
/* .el-input__wrapper{
    width: 550px;
    height: 40px;
    border-color: red;
  } */
  .dialogBtn{
      margin-left: 270px;
  }
</style>